/* This NetX test concentrates on fragment IPv6 packet with hop by hop option.  */

#include   "nx_api.h"
#include   "nx_ram_network_driver_test_1500.h"

extern void  test_control_return(UINT status);
#if !defined(NX_DISABLE_FRAGMENTATION) && defined(FEATURE_NX_IPV6) && !defined(NX_ENABLE_INTERFACE_CAPABILITY)
#define     DEMO_STACK_SIZE         2048


/* Define the ThreadX and NetX object control blocks...  */

static TX_THREAD               ntest_0;

static NX_PACKET_POOL          pool_0;
static NX_IP                   ip_0;
static NX_IP                   ip_1;
static NXD_ADDRESS             addr_0, addr_1;

/* Define the counters used in the test application...  */

static ULONG                   error_counter;


/* Define thread prototypes.  */

static void    ntest_0_entry(ULONG thread_input);
extern void    _nx_ram_network_driver_512(struct NX_IP_DRIVER_STRUCT *driver_req);
extern UINT    (*advanced_packet_process_callback)(NX_IP *ip_ptr, NX_PACKET *packet_ptr, UINT *operation_ptr, UINT *delay_ptr);
static UINT    packet_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr, UINT *operation_ptr, UINT *delay_ptr);

/* ICMPv6 echo request packet with hop by hop option.
 * src: 0xFE80::1
 * dst: 0xFE80::2 
 * length of ping data: 1400. */
static char icmp_pkt[] = {
0xa4, 0x1f, 0x72, 0x53, 0xa0, 0xf7, 0x18, 0x03, /* ..rS.... */
0x73, 0x29, 0x5f, 0x66, 0x86, 0xdd, 0x60, 0x00, /* s)_f..`. */
0x00, 0x00, 0x05, 0x88, 0x00, 0x40, 0xfe, 0x80, /* .....@.. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3a, 0x00, /* ......:. */
0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, /* ........ */
0x18, 0xd2, 0x00, 0x00, 0x00, 0x00, 0x61, 0x62, /* ......ab */
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* opqrstuv */
0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* wabcdefg */
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* hijklmno */
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* pqrstuvw */
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, /* abcdefgh */
0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* ijklmnop */
0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, /* qrstuvwa */
0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* bcdefghi */
0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, /* jklmnopq */
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, /* rstuvwab */
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, /* cdefghij */
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, /* klmnopqr */
0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, /* stuvwabc */
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, /* tuvwabcd */
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, /* efghijkl */
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, /* mnopqrst */
0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, /* uvwabcde */
0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, /* fghijklm */
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, /* nopqrstu */
0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* vwabcdef */
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, /* ghijklmn */
0x6f, 0x70, 0x71, 0x72, 0x73, 0x74              /* opqrst */
};

/* Define what the initial system looks like.  */

#ifdef CTEST
VOID test_application_define(void *first_unused_memory)
#else
void    netx_ipv6_hop_by_hop_fragment_test_application_define(void *first_unused_memory)
#endif
{

CHAR    *pointer;
UINT    status;

    
    /* Setup the working pointer.  */
    pointer =  (CHAR *) first_unused_memory;

    /* Create the main thread.  */
    tx_thread_create(&ntest_0, "thread 0", ntest_0_entry, 0,  
            pointer, DEMO_STACK_SIZE, 
            4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
    pointer =  pointer + DEMO_STACK_SIZE;

    /* Initialize the NetX system.  */
    nx_system_initialize();

    /* Create a packet pool.  */
    status =  nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 1536, pointer, 15360);
    pointer = pointer + 15360;

    if (status)
        error_counter++;

    /* Create an IP instance.  */
    status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 4), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_512,
                    pointer, 2048, 1);
    pointer =  pointer + 2048;

    /* Create an IP instance.  */
    status += nx_ip_create(&ip_1, "NetX IP Instance 1", IP_ADDRESS(1, 2, 3, 5), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_512,
                    pointer, 2048, 1);
    pointer =  pointer + 2048;

    /* Enable ICMP processing.  */
    status +=  nxd_icmp_enable(&ip_0);
    status +=  nxd_icmp_enable(&ip_1);
  
    /* Enable IPv6 */
    status += nxd_ipv6_enable(&ip_0); 
    status += nxd_ipv6_enable(&ip_1); 
  
    /* Enable fragmentation */
    status += nx_ip_fragment_enable(&ip_0); 
    status += nx_ip_fragment_enable(&ip_1); 

    /* Enable RAW packet for IP_0.*/
    status += nx_ip_raw_packet_enable(&ip_0);

    /* Check status.  */
    if(status)
        error_counter++;        
}



/* Define the test threads.  */

static void    ntest_0_entry(ULONG thread_input)
{

UINT        status;
NX_PACKET  *packet_ptr;

    
    /* Print out test information banner.  */
    printf("NetX Test:   IPv6 Hop by Hop Fragment Test.............................");

    /* Check for earlier error.  */
    if (error_counter)
    {

        printf("ERROR!\n");
        test_control_return(1);
    }

    /* Set IPv6 address. */
    addr_0.nxd_ip_version = NX_IP_VERSION_V6;
    addr_0.nxd_ip_address.v6[0] = 0xFE800000;
    addr_0.nxd_ip_address.v6[1] = 0x00000000;
    addr_0.nxd_ip_address.v6[2] = 0x00000000;
    addr_0.nxd_ip_address.v6[3] = 0x00000001;
    addr_1.nxd_ip_version = NX_IP_VERSION_V6;
    addr_1.nxd_ip_address.v6[0] = 0xFE800000;
    addr_1.nxd_ip_address.v6[1] = 0x00000000;
    addr_1.nxd_ip_address.v6[2] = 0x00000000;
    addr_1.nxd_ip_address.v6[3] = 0x00000002;
    
    status = nxd_ipv6_address_set(&ip_0, 0, &addr_0, 10, NX_NULL);
    status += nxd_ipv6_address_set(&ip_1, 0, &addr_1, 10, NX_NULL);

    /* Check status */
    if(status)
    {

        printf("ERROR!\n");
        test_control_return(1);
    }

    /* DAD. */
    tx_thread_sleep(5 * NX_IP_PERIODIC_RATE);

    /* Set driver filter to replace echo request packet. */
    advanced_packet_process_callback = packet_process;

    /* Ping IP_1. */
    status = nxd_icmp_ping(&ip_0, &addr_1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 28, &packet_ptr, NX_IP_PERIODIC_RATE);

    /* Check status */
    if(status)
    {

        printf("ERROR!\n");
        test_control_return(1);
    }

    /* Check the length. */
    if (packet_ptr -> nx_packet_length != 1400)
    {

        printf("ERROR!\n");
        test_control_return(1);
    }

    nx_packet_release(packet_ptr);

    printf("SUCCESS!\n");
    test_control_return(0);
}


static UINT    packet_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr, UINT *operation_ptr, UINT *delay_ptr)
{
NX_PACKET *my_packet;

    if ((ip_ptr == &ip_0) && (packet_ptr -> nx_packet_length == 76))
    {

        /* Drop the packet.  */
        *operation_ptr = NX_RAMDRIVER_OP_DROP;

        /* Inject Echo Request packet. */
        if (nx_packet_allocate(&pool_0, &my_packet, NX_IPv6_PACKET, NX_WAIT_FOREVER) == NX_SUCCESS)
        {

            /* Fill in the packet with data. Skip the MAC and IPv6 header.  */
            memcpy(my_packet -> nx_packet_prepend_ptr, &icmp_pkt[54], sizeof(icmp_pkt) - 54);
            my_packet -> nx_packet_length = sizeof(icmp_pkt) - 54;
            my_packet -> nx_packet_append_ptr = my_packet -> nx_packet_prepend_ptr + my_packet -> nx_packet_length;

            /* Send by RAW service. */
            nxd_ip_raw_packet_send(ip_ptr, my_packet, &addr_1, NX_PROTOCOL_NEXT_HEADER_HOP_BY_HOP, 255, NX_IP_NORMAL);
        }
    }

    return NX_TRUE;
}
#else
#ifdef CTEST
VOID test_application_define(void *first_unused_memory)
#else
void    netx_ipv6_hop_by_hop_fragment_test_application_define(void *first_unused_memory)
#endif
{

    /* Print out some test information banners.  */
    printf("NetX Test:   IPv6 Hop by Hop Fragment Test.............................N/A\n");
    test_control_return(3);
}
#endif /* NX_DISABLE_ICMP_INFO */
